<template>
<div>
	<el-form label-width="80px" :model="taskForm" :rules="rules">
    <el-form-item label="标题" prop="title">
      <el-input v-model="taskForm.title" placeholder="请输入任务名称"></el-input>
    </el-form-item>
  	<el-form-item label="负责人" prop="member">
      <Member :member_value="taskForm.member" @saveMember="saveMember"></Member>
    </el-form-item>
    <el-form-item label="优先级">
      <el-select v-model="taskForm.priority">
      	<el-option label="高" value="hight"></el-option>
      	<el-option label="中" value="middle"></el-option>
      	<el-option label="低" value="low"></el-option>
      </el-select>
    </el-form-item>
    <el-form-item label="开始时间" prop="begin_date">
      <el-date-picker
	      v-model="taskForm.begin_date"
	      type="date"
	      format="yyyy年MM月dd日"
	      placeholder="选择日期">
	    </el-date-picker>
    </el-form-item>
  	<el-form-item label="截止时间" prop="end_date">
      <el-date-picker
	      v-model="taskForm.end_date"
	      type="date"
	      format="yyyy年MM月dd日"
	      placeholder="选择日期">
	    </el-date-picker>
    </el-form-item>
    <el-form-item label="描述" prop="desc">
      <el-input 
      	type="textarea"
      	placeholder="请输入任务描述"
      	:autosize="{ minRows: 5, maxRows: 20}"
      	v-model="taskForm.desc"></el-input>
    </el-form-item>
  </el-form>
  <div slot="footer" class="dialog-footer">
    <el-button type="primary" @click="saveTask">保存</el-button>
  </div>
</div>
</template>

<script>
import Member from './member'
export default {
	props: {
		taskForm: Object
	},
	components: {
		Member
	},
	data () {
		return {
			taskVisible: false,
      rules: {
        title: [{required: true, message: '请输入标题'}],
        begin_date: [{required: true, message: '请选择开始日期'}],
        member: [{type:'array', required: true, message: '请选择负责人', trigger: 'change'}],
        end_date: [{required: true, message: '请选择截止日期'}],
        desc: [{required: true, message: '请输入任务描述, 让别人知道要做什么'}]
      }
		}
	},
	methods: {
		saveTask () {
			this.$emit('saveSubTask',this.taskForm)
		},
		saveMember (members) {
    	this.taskForm.member = members
    }
	}
}
</script>